home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 671 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.4 KB  |  72 lines

  1. Path: mail2news.demon.co.uk!wbriscoe.demon.co.uk
  2. From: walter briscoe <walter@wbriscoe.demon.co.uk>
  3. Newsgroups: comp.std.c
  4. Subject: Re: Close all opened files in C ?
  5. Date: Fri, 29 Mar 96 13:17:38 GMT
  6. Message-ID: <828105458snz@wbriscoe.demon.co.uk>
  7. References: <4jgifa$fjd@chaos.kulnet.kuleuven.ac.be>
  8. Reply-To: walter@wbriscoe.demon.co.uk
  9. X-NNTP-Posting-Host: wbriscoe.demon.co.uk
  10. X-Newsreader: Demon Internet Simple News v1.30
  11. X-Mail2News-Path: wbriscoe.demon.co.uk
  12.  
  13. In article <4jgifa$fjd@chaos.kulnet.kuleuven.ac.be>
  14.            christian.felique@student.kuleuven.ac.be "christian felique" writes:
  15.  
  16. > I am using a shareware C routine to play a sound sample
  17. > throught the PC speaker. 
  18. > SoundPlay("SAMPLE.VOC",delay,twiddle);
  19. > I think that the programmer
  20. > of the routine has forgotten to take care of closing the sample file
  21. > after it is played, because the routine will not work anymore after a few
  22. > calls (about 10 calls) (It displays an Out of Memory message)
  23. > I think that the Out of Memory error has got nothing to
  24. > do with the size of a sound sample file, because:
  25. > * You can call the routine for about 10 times using a small sample.
  26. > *            " " " " " """"""""""""""10  """"""""""""large """""""
  27. > According to me, the reason for the out of memory error
  28. > is the fact that there are too many file buffers open .
  29. > NOW THIS IS MY QUESTION:
  30. > How can I close all files that are opened ?
  31. > I can't use fclose(...) because fclose needs a file pointer as
  32. > an argument. 
  33. > If you know how to solve this problem in Quick C or
  34. > inline assembly. Then send me your answer
  35. > to:
  36.  
  37. This thread is inappropriate in comp.std.c.
  38.  
  39. Not as inappropriate as the "help wanted" threads which recently
  40. appeared and I ignored those.
  41.  
  42. I suggest comp.lang.c.moderated may be appropriate.
  43.  
  44. My first thought was that fclose ( 0 ) should do the job by analogy with
  45. fflush ( 0 ) but the standard library is not orthogonal.
  46.  
  47. I don't know quickc's limitations but in Borland C++ 3.1 can:
  48.  
  49. #include <stdio.h>     or #include <io.h>
  50. (void)fcloseall           int i = 6; while (!close(i++));
  51.  
  52. or the assembly to close a file with a given handle is:
  53.         mov     bx, Handle           ; Handle of file or device
  54.         mov     ah, 3Eh              ; Close File with Handle
  55.         int     21h                  ; Do it
  56.         jc      error_handler        ; carry set on error
  57.  
  58. ax contains a standard DOS error code on failure.
  59. --
  60. walter briscoe
  61.